﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//using DG.Tweening;
using UnityEngine.UI;
public class RotatManager : MonoBehaviour {

	// Use this for initialization


    public Transform UI_1;
    public Transform RotatObj;

  
    public void ExitManager()
    {
        Application.Quit();
    }
    public void OpenUI()
    {
        if (!UI_1.gameObject.activeSelf)
        {
            UI_1.gameObject.SetActive(true);
        }
        else
        {
            UI_1.gameObject.SetActive(false);
        }
    }

    public Transform[] m_SpeedUI;
    public float[] m_Speed;
    public float RotatSpeed;
    public void SetSpeed(int  index)
    {
        //RotatObj.GetComponent<DOTweenAnimation>().duration = m_Speed[index];
        //print(RotatObj.GetComponent<DOTweenAnimation>().duration);
        RotatSpeed = m_Speed[index];
        //RotatObj.DOLocalRotate(new Vector3(0, 0, -180), RotatSpeed,RotateMode.FastBeyond360);
        for (int i = 0; i < m_SizeUI.Length; i++)
        {
            if (i == index)
            {
                m_SpeedUI[i].GetChild(0).GetChild(0).gameObject.SetActive(true);
            }
            else
            {
                m_SpeedUI[i].GetChild(0).GetChild(0).gameObject.SetActive(false);
            }
        }

        
    }

    public Transform[] m_SizeUI;
    public float[] m_Size;
    public void SetSize(int index)
    {
        RotatObj.localScale = Vector3.one * m_Size[index];
   
        for (int i = 0; i < m_SizeUI.Length; i++)
        {
            if (i == index)
            {
                m_SizeUI[i].GetChild(0).GetChild(0).gameObject.SetActive(true);
            }
            else
            {
                m_SizeUI[i].GetChild(0).GetChild(0).gameObject.SetActive(false);
            }
        }
    }
	void Start () {
		
	}
	
	// Update is called once per frame
    public bool isRotat;
    void Update()
    {
        if (isRotat)
        RotatObj.eulerAngles = new Vector3(0, 0, RotatObj.eulerAngles.z - (RotatSpeed * Time.deltaTime));
    }
}
